#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void swap(int* a, int* b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}
void selectsort(int* a, int n)
{
	int begin = 0, end = n - 1;
	while (begin < end)
	{
		int max = begin;
		int min = begin;
		for (size_t i = begin; i <= end; i++)
		{
			if (a[i] > a[max])
			{
				max = i;
			}
			if (a[i] < a[min])
			{
				i = min;
			}
		}
		swap(&a[min], &a[begin]);
		swap(&a[max], &a[end]);
		begin++;
		end--;
	}


}
int main()
{
	int a[6] = { 1,4,6,5,2,4 };
	//shellsort(a, 6, 3);
	//shellsort(a, 6, 2);
	//shellsort(a, 6, 1);
	selectsort(a, 6);
	for (int i = 0; i < 6; i++)
	{
		printf("%d", a[i]);
	}

	return 0;
}


